<template>
	<view class="ys">
		<view class="title">
			留言标题
		</view>
		<view class="inputbox">
			<input type="text" v-model="title" placeholder="请输入留言标题">
		</view>
		<view class="title">
			留言内容
		</view>
		<view class="inputbox">
			<textarea v-model="content" placeholder="请输入留言内容"></textarea>
		</view>
		<button class="btn" @tap="FeedBackAdd" :loading="loading" :disabled="loading">立即留言</button>
	</view>
</template>

<script>
	import {
		feedback
	} from "@/api/api.js"
	export default {
		data() {
			return {
				loading: false,
				title: '',
				content: '',
				imglist: [],
				feedid: '',
				order_num: '',
				phone: '',
				img: ''
			}
		},
		onLoad() {

		},
		methods: {

			FeedBackAdd() {
				if (this.loading) {
					return false
				}
				if (this.title == '') {
					uni.showToast({
						title: '请输入留言标题',
						icon: "none"
					})
					return
				}
				if (this.content == '') {
					uni.showToast({
						title: '请输入留言内容',
						icon: "none"
					})
					return
				}
				this.loading = true
				feedback({
					title: this.title,
					content: this.content,
				}).then(res => {
					uni.$showMsg(res.msg)
					if (res.code == 0) {
						setTimeout(() => {
							uni.navigateBack()
						}, 1000)
					} else {
						this.loading = false
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		padding-bottom: 10px;
	}

	.nav {
		display: flex;
		width: 94%;
		margin: 0 auto;
		height: 40px;
		line-height: 40px;

		.navitem {
			flex: 1;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			color: #999;
			font-size: 16px;
			font-weight: bold;

			.line {
				display: grid;
				height: 3px;
				width: 100%;
				background: #eee;
			}
		}

		.active {
			color: #F04D2F;

			.line {
				background: #F04D2F;
			}
		}
	}

	.imgbox {
		width: 90%;
		margin: 0 auto;
		display: flex;
		flex-wrap: wrap;

		.img-item {
			width: 24vw*0.9;
			height: 24vw*0.9;
			margin-right: 1%;
			position: relative;

			text {
				background: #ff0000;
				width: 18px;
				height: 18px;
				line-height: 18px;
				position: absolute;
				top: 0;
				right: 0;
				text-align: center;
			}

			image {
				width: 100%;
				height: 100%;
				border-radius: 5px;
			}
		}


		.addimg {
			width: 24vw*0.9;
			height: 24vw*0.9;
			border: 1px solid #eee;
			border-radius: 5px;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}

	.tips {
		display: flex;
		align-items: center;
		padding: 10px;
		font-size: 12px;
		border-bottom: 1px solid #ccc;
	}

	.title {
		padding: 10px 0;
		width: 90%;
		font-weight: bold;
		margin: 0 auto;
		font-size: 15px;

		text {
			font-weight: normal;
			font-size: 12px;
			color: #999;
			margin-left: 5px;
		}
	}

	.inputbox {
		input {
			padding: 2%;
			width: 88%;
			margin: 0 auto;
			border: 1px solid #ccc;
			border-radius: 5px;
			font-size: 14px;
		}

		.tipsbox {
			width: 90%;
			margin: 0 auto;
			display: flex;
			flex-wrap: wrap;

			.tips_item {
				font-size: 12px;
				color: #999;
				border: 1px solid #eee;
				border-radius: 5px;
				padding: 3px 20px;
				margin: 5px 15px;
				margin-left: 0;
			}

			.active {
				color: #F04D2F;
				border-color: #F04D2F;
			}
		}

		textarea {
			padding: 2%;
			width: 88%;
			margin: 0 auto;
			border: 1px solid #ccc;
			border-radius: 5px;
			font-size: 14px;
		}
	}

	.btn {
		width: 90%;
		margin-top: 20px;
		letter-spacing: 2px;
		background: $uni-bg-color;
		color: #fff;
		font-size: 14px;
	}
</style>